package com.klhappy.houyuan.view;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.klhappy.houyuan.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;

public class ImageManager {
	private static DisplayImageOptions opts = new DisplayImageOptions.Builder()
			.showImageOnLoading(R.drawable.default_square)
			.showImageForEmptyUri(R.drawable.default_square)
			.showImageOnFail(R.drawable.default_square).cacheInMemory(true)
			.cacheOnDisc(true).imageScaleType(ImageScaleType.EXACTLY)
			// .memoryCache(new WeakMemoryCache())
			// .displayer(new RoundedBitmapDisplayer(20))//
			// 是否设置为圆角，弧度为多
			.bitmapConfig(Bitmap.Config.RGB_565).build();

	private static DisplayImageOptions opt = new DisplayImageOptions.Builder()
			.showImageOnLoading(R.drawable.liangpiao_img)
			.showImageForEmptyUri(R.drawable.liangpiao_img)
			.showImageOnFail(R.drawable.liangpiao_img).cacheInMemory(true)
			.cacheOnDisc(true).imageScaleType(ImageScaleType.EXACTLY)
					// .memoryCache(new WeakMemoryCache())
					// .displayer(new RoundedBitmapDisplayer(20))//
					// 是否设置为圆角，弧度为多
			.bitmapConfig(Bitmap.Config.RGB_565).build();
	/**
	 * @param url
	 * @param view
	 *            加载的图片所
	 */
	public static void loadImage(String url, ImageView imageView) {
		ImageLoader loader = ImageLoader.getInstance();
		loader.displayImage(url, new ImageViewAware(imageView), opts);
	}

	public static void loadImagex(String url, ImageView imageView) {
		ImageLoader loader = ImageLoader.getInstance();
		loader.displayImage(url, new ImageViewAware(imageView), opt);
	}

}
